﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WeChatParking.Core.BLL
{
    public class retry
    {
        public List<Payment.UnionPay.retry> Get(string filter, string OrderFields = "", bool isDesc = false)
        {
            using (var dbContext = Repository.DbContext.Create())
            {
                try
                {
                    string sql = "select * from retry";
                    if (filter.Length > 0)
                        sql += "  where  " + filter;
                    if (OrderFields.Length > 0)
                    {
                        if (isDesc)
                            sql += "   ORDER BY  " + OrderFields + "  DESC";

                        else
                            sql += "   ORDER BY  " + OrderFields;
                    }
                    return dbContext.GetListBySql<Payment.UnionPay.retry>(sql, null).ToList();
                }
                catch (Exception ex)
                {
                    LogHelper.Error(ex, "获取retry数据");
                    return null;
                }
            }
        }
        public int Add(Payment.UnionPay.retry model)
        {
            using (var dbContext = Repository.DbContext.Create())
            {
                return dbContext.Insert<Payment.UnionPay.retry>(model);
            }
        }
        public bool Update(Payment.UnionPay.retry model)
        {
            using (var dbContext = Repository.DbContext.Create())
            {
                model.num += 1;
                return dbContext.Update<Payment.UnionPay.retry>(model);
            }
        }
    }
}
